/**
 * Created with IntelliJ IDEA.
 * Description:
 */

import java.util.ArrayList;
import java.util.List;


class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode() {}
      TreeNode(int val) { this.val = val; }
      TreeNode(int val, TreeNode left, TreeNode right) {
          this.val = val;
          this.left = left;
          this.right = right;
      }
  }

class Solution {

    List<Integer> retlist = new ArrayList<>();
    public List<Integer> preorderTraversal(TreeNode root) {

        if(root == null){
            return retlist;
        }

        retlist.add(root.val);
        preorderTraversal(root.left);
        preorderTraversal(root.right);
        return retlist;
    }
}

